home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / file.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  7.5 KB  |  272 lines

  1. /*      FILE.H
  2.  *
  3.  * High-level file I/O for MIDAS Sound System
  4.  *
  5.  * $Id: file.h,v 1.2 1997/01/16 18:41:59 pekangas Exp $
  6.  *
  7.  * Copyright 1996,1997 Housemarque Inc.
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16. #ifndef __FILE_H
  17. #define __FILE_H
  18.  
  19. #include "rawfile.h"
  20.  
  21.  
  22. /****************************************************************************\
  23. *       struct fileFile
  24. *       ---------------
  25. * Description:  File state structure
  26. \****************************************************************************/
  27.  
  28. typedef struct
  29. {
  30.     rfHandle    rf;
  31. } fileFile;
  32.  
  33.  
  34.  
  35.  
  36. /****************************************************************************\
  37. *       typedef fileHandle
  38. *       ------------------
  39. * Description: High-level file I/O file handle
  40. \****************************************************************************/
  41.  
  42. typedef fileFile* fileHandle;
  43.  
  44.  
  45.  
  46. /****************************************************************************\
  47. *       enum fileOpenMode
  48. *       -----------------
  49. * Description:  File opening mode. Used by fileOpen()
  50. \****************************************************************************/
  51.  
  52. enum fileOpenMode
  53. {
  54.     fileOpenRead = 1,                   /* open file for reading */
  55.     fileOpenWrite = 2,                  /* open file for writing */
  56.     fileOpenReadWrite = 3               /* open file for both reading and
  57.                                            writing */
  58. };
  59.  
  60.  
  61.  
  62. /****************************************************************************\
  63. *       enum fileSeekMode
  64. *       -----------------
  65. * Description:  File seeking mode. Used by fileSeek()
  66. \****************************************************************************/
  67.  
  68. enum fileSeekMode
  69. {
  70.     fileSeekAbsolute = 1,               /* seek to an absolute position from
  71.                                            the beginning of the file */
  72.     fileSeekRelative = 2,               /* seek to a position relative to
  73.                                            current position */
  74.     fileSeekEnd = 3                     /* seek relative to the end of file */
  75. };
  76.  
  77.  
  78.  
  79. #ifdef __cplusplus
  80. extern "C" {
  81. #endif
  82.  
  83.  
  84. /****************************************************************************\
  85. *
  86. * Function:     int fileOpen(char *fileName, int openMode, fileHandle *file);
  87. *
  88. * Description:  Opens a file for reading or writing
  89. *
  90. * Input:        char *fileName          name of file
  91. *               int openMode            file opening mode, see enum rfOpenMode
  92. *               fileHandle *file        pointer to file handle
  93. *
  94. * Returns:      MIDAS error code.
  95. *               File handle is stored in *file.
  96. *
  97. \****************************************************************************/
  98.  
  99. int CALLING fileOpen(char *fileName, int openMode, fileHandle *file);
  100.  
  101.  
  102.  
  103.  
  104. /****************************************************************************\
  105. *
  106. * Function:     int fileClose(fileHandle file);
  107. *
  108. * Description:  Closes a file opened with fileOpen().
  109. *
  110. * Input:        fileHandle file         handle of an open file
  111. *
  112. * Returns:      MIDAS error code
  113. *
  114. \****************************************************************************/
  115.  
  116. int CALLING fileClose(fileHandle file);
  117.  
  118.  
  119.  
  120.  
  121. /****************************************************************************\
  122. *
  123. * Function:     int fileGetSize(fileHandle file, long *fileSize);
  124. *
  125. * Description:  Get the size of a file
  126. *
  127. * Input:        fileHandle file         handle of an open file
  128. *               ulong *fileSize         pointer to file size
  129. *
  130. * Returns:      MIDAS error code.
  131. *               File size is stored in *fileSize.
  132. *
  133. \****************************************************************************/
  134.  
  135. int CALLING fileGetSize(fileHandle file, long *fileSize);
  136.  
  137.  
  138.  
  139.  
  140. /****************************************************************************\
  141. *
  142. * Function:     int fileRead(fileHandle file, void *buffer, ulong numBytes);
  143. *
  144. * Description:  Reads binary data from a file
  145. *
  146. * Input:        fileHandle file         file handle
  147. *               void *buffer            reading buffer
  148. *               ulong numBytes          number of bytes to read
  149. *
  150. * Returns:      MIDAS error code.
  151. *               Read data is stored in *buffer, which must be large enough
  152. *               for it.
  153. *
  154. \****************************************************************************/
  155.  
  156. int CALLING fileRead(fileHandle file, void *buffer, ulong numBytes);
  157.  
  158.  
  159.  
  160.  
  161. /****************************************************************************\
  162. *
  163. * Function:     int fileWrite(fileHandle file, void *buffer, ulong numBytes);
  164. *
  165. * Description:  Writes binary data to a file
  166. *
  167. * Input:        fileHandle file         file handle
  168. *               void *buffer            pointer to data to be written
  169. *               ulong numBytes          number of bytes to write
  170. *
  171. * Returns:      MIDAS error code
  172. *
  173. \****************************************************************************/
  174.  
  175. int CALLING fileWrite(fileHandle file, void *buffer, ulong numBytes);
  176.  
  177.  
  178.  
  179.  
  180. /****************************************************************************\
  181. *
  182. * Function:     int fileSeek(fileHandle file, long newPosition, int seekMode);
  183. *
  184. * Description:  Seeks to a new position in file. Subsequent reads and writes
  185. *               go to the new position.
  186. *
  187. * Input:        fileHandle file         file handle
  188. *               long newPosition        new file position
  189. *               int seekMode            file seek mode, see enum rfSeekMode
  190. *
  191. * Returns:      MIDAS error code
  192. *
  193. \****************************************************************************/
  194.  
  195. int CALLING fileSeek(fileHandle file, long newPosition, int seekMode);
  196.  
  197.  
  198.  
  199.  
  200. /****************************************************************************\
  201. *
  202. * Function:     int fileGetPosition(fileHandle file, long *position);
  203. *
  204. * Description:  Reads the current position in a file
  205. *
  206. * Input:        fileHandle file         file handle
  207. *               long *position          pointer to file position
  208. *
  209. * Returns:      MIDAS error code.
  210. *               Current file position is stored in *position.
  211. *
  212. \****************************************************************************/
  213.  
  214. int CALLING fileGetPosition(fileHandle file, long *position);
  215.  
  216.  
  217.  
  218.  
  219. /****************************************************************************\
  220. *
  221. * Function:     int fileExists(char *fileName, int *exists);
  222. *
  223. * Description:  Checks if a file exists or not
  224. *
  225. * Input:        char *fileName          file name, ASCIIZ
  226. *               int *exists             pointer to file exists status
  227. *
  228. * Returns:      MIDAS error code.
  229. *               *exists contains 1 if file exists, 0 if not.
  230. *
  231. \****************************************************************************/
  232.  
  233. int CALLING fileExists(char *fileName, int *exists);
  234.  
  235.  
  236.  
  237.  
  238. #ifdef __cplusplus
  239. }
  240. #endif
  241.  
  242.  
  243.  
  244. /****************************************************************************\
  245. *       enum fileFunctIDs
  246. *       -----------------
  247. * Description:  ID numbers for high-level file I/O functions
  248. \****************************************************************************/
  249.  
  250. enum fileFunctIDs
  251. {
  252.     ID_fileOpen = ID_file,
  253.     ID_fileClose,
  254.     ID_fileGetSize,
  255.     ID_fileRead,
  256.     ID_fileWrite,
  257.     ID_fileSeek,
  258.     ID_fileGetPosition,
  259.     ID_fileExists
  260. };
  261.  
  262. #endif
  263.  
  264. /*
  265.  * $Log: file.h,v $
  266.  * Revision 1.2  1997/01/16 18:41:59  pekangas
  267.  * Changed copyright messages to Housemarque
  268.  *
  269.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  270.  * Initial revision
  271.  *
  272. */